const Mock = require('mockjs')

const List = []
const count = 100

const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment',
    'train_time|2': Mock.Random.date('yyyy-MM-dd'),
    timestamp: +Mock.Random.date('T'),
    birthday: +Mock.Random.date('T'),
    // 'playerlist|5': ['熊桂英', '于军', '杜洋', '阎敏', '苏勇', '朱丽', '薛平', '潘娟', '彭霞', '宋平'],
    playerlist: '@shuffle(["熊桂英", "于军", "杜洋", "阎敏", "苏勇", "朱丽", "薛平", "潘娟", "彭霞", "宋平"], 5)',
    Birthday: +Mock.Random.date('T'),
    age: '@integer(20, 30)',
    Age: '@integer(20, 30)',
    height: '@integer(175, 195)',
    Height: '@integer(175, 195)',
    weight: '@integer(70, 90)',
    Weight: '@integer(70, 90)',
    playerName: '@cname',
    Chinese_name: '@cname',
    'Cure|1': ['物理治疗', '药物治疗'],
    coachName: '@cname',
    author: '@cname',
    chinese_name: '@cname',
    'Id_code': '@integer(125632140123215412, 198745632101245214)',
    'crunit': '@city(true)',
    'train_position': '@city(true)',
    reviewer: '@integer(125632140123215412, 198745632101245214)',
    title: '@cname',
    content_short: 'mock data',
    content: baseContent,
    forecast: '@float(0, 100, 2, 2)',
    importance: '@integer(1, 3)',
    'type|1': ['CN', 'US', 'JP', 'EU'],
    'status|1': ['集训', '比赛'],
    'train_name|1': ['备战2020比赛', '球队集体拉练'],
    'State|1': ['中国', '外籍'],
    display_time: '@datetime',
    comment_disabled: true,
    'Hometaeam_score|1': '@integer(0, 5)',
    'Totaltime': '@integer(0, 90)',
    'Is_start|1': ['是', '否'],
    'Chinese_name|1': '@cname',
    'Visitingteam_score|1': '@integer(0, 5)',
    'team_name|1': ['大连人', '深圳佳兆业', '青岛黄海青港', '河北华夏幸福', '上海绿地申花'],
    'teamName1|1': ['大连人', '深圳佳兆业', '青岛黄海青港', '河北华夏幸福', '上海绿地申花'],
    'competition|1': ['中国足球协会杯', '中国足球协会超级杯', '中国足球协会超级联赛', '中国足球协会甲级联赛', '中国足球协会乙级联赛'],
    'teamName|1': ['北京国安', '山东鲁能', '天津泰达', '辽宁宏运', '青岛黄海', '河南建业', '重庆力帆'],
    'gamePosition|1': ['前锋', '中锋', '前腰', '中场', '后腰', '后卫', '守门员'],
    'Position|1': ['前锋', '中锋', '前腰', '中场', '后腰', '后卫', '守门员'],
    'importanceOptions|1': ['第一赛季', '第二赛季', '第三赛季'],
    'teamType|1': ['中超', '中甲', '中乙'],
    'Team_name|1': ['北京国安', '山东鲁能', '天津泰达', '辽宁宏运', '青岛黄海', '河南建业', '重庆力帆'],
    'position|1': ['前锋', '中锋', '前腰', '中场', '后腰', '后卫', '守门员'],
    // 'Position|1': ['前锋', '中锋', '前腰', '中场', '后腰', '后卫', '守门员'],
    'video_thumbnail|1': ['../../video/imgs/', '../../video/imgs/', '../../video/imgs/'],
    'video_keyword|1': ['视频关键字'],
    'video_name|1': ['里奥·梅西', '孔德宝', '内马尔', '李毅', 'C罗', '王霜'],
    'Hformation_data|1': ['4-3-3', '3-4-3', '5-4-1', '5-3-2', '4-5-1'],
    'Vformation_data|1': ['4-3-3', '3-4-3', '5-4-1', '5-3-2', '4-5-1'],
    'Injurytypeid|1': ['骨折', '跟腱断裂', '头破血流'],
    'Injury_position|1': ['头部', '躯干', '脚部'],
    'Injury_level|1': ['轻伤', '重伤', '报销'],
    'Nation_doctorid|1': ['华佗', '张仲景', '扁鹊'],
    'Club_doctorid|1': ['华佗', '张仲景', '扁鹊'],
    'Injury_location|1': ['上海', '广州', '北京', '深圳', '珠海'],
    'newstitle|1': ['关于教练员填写训练计划的通知', '关于中秋节放假的通知', '关于五月份总结大会的通知', '友谊赛通知'],
    Backdate: '@integer(1, 90)',
    'Player_uniform': '@integer(0, 5)',
    pageviews: '@integer(300, 5000)',
    image_uri,
    platforms: ['a-platform'],
    player_name: '@cname',
    left_leg: '@integer(70, 90)',
    right_leg: '@integer(70, 90)',
    bodyfat: '@integer(70, 90)',
    flexibility: '@integer(70, 90)',
    verticaljump: '@integer(70, 90)',
    meter_sprint: '@integer(70, 90)',
    arrowrun: '@integer(70, 90)',
    yoyoir2: '@integer(70, 90)',
    push_up: '@integer(70, 90)',
    pull_up: '@integer(70, 90)',
    'test_position|1': ['体育馆一', '体育馆二', '体育馆三'],
    'urine_gravity|1.3': 1,
    'ph|1.3': 1,
    'urobilinogen|1.3': 1,
    'urine_protein|1.3': 1,
    'period_name|1': ['场次1', '场次2', '场次3'],
    'position_name|1': ['前锋', '中锋', '前腰', '中场', '后腰', '后卫', '守门员'],
    unix_start_time: Mock.Random.date('T'),
    unix_end_time: +Mock.Random.date('T'),
    total_time: +Mock.Random.date('T'),
    total_distance: '@integer(175, 195)',
    total_player_load: '@integer(175, 195)',
    mmin: '@integer(175, 195)',
    max_heartrate: '@integer(175, 195)',
    load_permetre: '@integer(175, 195)',
    // 用户
    user_id: '@increment',
    'user_type|1': ['国家队管理员', '联赛管理员', '俱乐部管理员', '普通用户', '球探', '教练', '队医'],
    account: Mock.Random.string('number', 8, 10),
    password: '@increment',
    username: '@cname',
    'sex|1': ['男', '女'],
    'email|1': ['8215555@qq.com', '4855222466@qq.com'],
    'telephone|1': ['12255856657', '12255565555'],
    'create_founder|1': ['admin', 'admin2'],
    create_time: Mock.Random.date('yyyy-MM-dd'),
    due_time: Mock.Random.date('yyyy-MM-dd'),
    'id_code|1': ['622625198701011023', '622625198701011023'],
    'state|1': ['中国', '美国', '新加坡', '日本', '印度'],
    'module_authority|1': [{ 'teammodule': '1111', 'matchmodule': '1111', 'playermodule': '1111' }],
    'update_userid|1': ['admin', 'admin2'],
    update_time: +Mock.Random.date('T'),
    uniform_number: '@integer(0, 100)',
    train_content: '1,训练时间(每天下午17:00至19:00)礼拜六至礼拜天热身训练赛<br>2,训练地点:泾县稼祥中学<br>3,参加人员:折木队员<br>4,教练组:全体教练组<br>5,训练要求:每一位参加训练的队员,态度端正,积极拼抢,按时按量的完成教练组安排的训练任务,虚心学习,团结队友,为奋力拼搏,勇往直前！<br>6,训练目的:通过训练,使参加训练的队员,在短期内提高体能,技战术,身体对抗等方面<br>'
  }))
}
module.exports = [
  {
    url: '/vue-element-admin/article/list',
    type: 'get',
    response: config => {
      const { type, weightvalue = [60, 90], importanceOptions, teamName, playerName, competition, heightvalue = [160, 200], agevalue = [10, 40], title, player_name, page = 1, limit = 20, sort } = config.query

      let mockList = List.filter(item => {
        // if (importance && item.importance !== +importance) return false
        if (type && item.type !== type) return false
        if (importanceOptions && item.importanceOptions !== importanceOptions) return false
        if (teamName && item.teamName !== teamName) return false
        if (playerName && item.playerName.indexOf(playerName) < 0) return false
        if (competition && item.competition.indexOf(competition) < 0) return false
        if (title && item.title.indexOf(title) < 0) return false
        if (player_name && item.player_name.indexOf(player_name) < 0) return false
        if (agevalue && (item.age > agevalue[1] || item.age < agevalue[0])) return false
        if (heightvalue && (item.height > heightvalue[1] || item.height < heightvalue[0])) return false
        if (weightvalue && (item.weight > weightvalue[1] || item.weight < weightvalue[0])) return false
        return true
      })
      if (sort === '-id') {
        mockList = mockList.reverse()
      }

      const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
        code: 20000,
        data: {
          total: mockList.length,
          items: pageList
        }
      }
    }
  },

  {
    url: '/vue-element-admin/article/detail',
    type: 'get',
    response: config => {
      const { id } = config.query
      for (const article of List) {
        if (article.id === +id) {
          return {
            code: 20000,
            data: article
          }
        }
      }
    }
  },

  {
    url: '/vue-element-admin/article/pv',
    type: 'get',
    response: _ => {
      return {
        code: 20000,
        data: {
          pvData: [
            { key: 'PC', pv: 1024 },
            { key: 'mobile', pv: 1024 },
            { key: 'ios', pv: 1024 },
            { key: 'android', pv: 1024 }
          ]
        }
      }
    }
  },

  {
    url: '/vue-element-admin/article/create',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  },

  {
    url: '/vue-element-admin/article/update',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]
